package cn.opopopo.design_pattern_learn.结构型.composite;

import java.util.*;

class Directory extends FileSystemComponent {
    private List<FileSystemComponent> children = new ArrayList<>();

    public Directory(String name) {
        super(name);
    }

    @Override
    public void showDetails() {
        System.out.println("📁 文件夹: " + name + "/");
        for (FileSystemComponent child : children) {
            child.showDetails(); // 递归调用
        }
    }

    @Override
    public void add(FileSystemComponent component) {
        children.add(component);
    }

    @Override
    public void remove(FileSystemComponent component) {
        children.remove(component);
    }

    @Override
    public List<FileSystemComponent> getChildren() {
        return children;
    }
}